<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>名片编辑</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  {include file="public/css"/}
	<style>
	#ggnamediv .layui-input,#ggvaldiv .layui-input{ display:inline;height:30px}
	</style>
</head>
<body>
  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-card layui-col-md12">
				<div class="layui-card-header">
					{if !$info['id']}<i class="fa fa-plus"></i> 添加名片{else}<i class="fa fa-pencil"></i> 编辑名片{/if}
					<i class="layui-icon layui-icon-close" style="font-size:18px;font-weight:bold;cursor:pointer" onclick="closeself()"></i>
				</div>
				<div class="layui-card-body" pad15>
					<div class="layui-form">
						<div class="layui-tab" lay-filter="mytab">
							<ul class="layui-tab-title">
								<li class="layui-this" lay-id="1">基本信息</li>
								<li lay-id="2">个人简介</li>
							</ul>
							<div class="layui-tab-content">
								<div class="layui-tab-item layui-show">
									<input type="hidden" name="info[id]" value="{$info.id}"/>
									
									<div class="layui-form-item">
										<label class="layui-form-label">名片背景：</label>
										{if !getcustom('mingpian_banner')}
										<input type="hidden" name="info[bgpic]" id="bgpic" lay-verType="tips" class="layui-input" value="{$info.bgpic}">
										<button style="float:left;" type="button" class="layui-btn layui-btn-primary"  onclick="uploader(this)" upload-input="bgpic" upload-preview="bgpicPreview">上传图片</button>
										<div class="layui-form-mid layui-word-aux" style="margin-left:10px;">建议尺寸：700×480像素</div>
										<div id="bgpicPreview" style="float:left;padding-top:10px;padding-left:110px;clear: both;">
											<div class="layui-imgbox" style="width:100px;;height:71px"><div class="layui-imgbox-img"><img src="{$info.bgpic}"/></div></div>
										</div>
										{/if}
										{if getcustom('mingpian_banner')}
										{if $set['bgpic_banner'] == 1}
										<input type="hidden" name="info[bgpics]" value="{$info['bgpics']}" id="bgpics">
										<button style="float:left;" type="button" class="layui-btn layui-btn-primary" onclick="uploader(this,true,false,'',9,true)" upload-input="bgpics" upload-preview="picList" >批量上传</button>
										<div class="layui-form-mid layui-word-aux" style="margin-left:10px;">建议尺寸：640×640像素，最多9张。</div>
										<div id="picList" class="picsList-class-padding" style="float:left;padding-top:10px;padding-left:110px;clear: both;">
											{if $info['bgpics']}{foreach $info['bgpics'] as $pic}
												<div class="layui-imgbox">
													<a class="layui-imgbox-close" href="javascript:void(0)" onclick="$(this).parent().remove();getpicsval('bgpics','picList')" title="删除"><i class="layui-icon layui-icon-close-fill-opaque"></i></a>
													<span class="layui-imgbox-img"><img src="{$pic}"></span>
												</div>
											{/foreach}{/if}
										</div>
										{/if}
										{if $set['bgpic_banner'] != 1}
											<input type="hidden" name="info[bgpic]" id="bgpic" lay-verType="tips" class="layui-input" value="{$info.bgpic}">
											<button style="float:left;" type="button" class="layui-btn layui-btn-primary"  onclick="uploader(this)" upload-input="bgpic" upload-preview="bgpicPreview">上传图片</button>
											<div class="layui-form-mid layui-word-aux" style="margin-left:10px;">建议尺寸：700×480像素</div>
											<div id="bgpicPreview" style="float:left;padding-top:10px;padding-left:110px;clear: both;">
												<div class="layui-imgbox" style="width:100px;;height:71px"><div class="layui-imgbox-img"><img src="{$info.bgpic}"/></div></div>
											</div>
										{/if}
										{/if}
									</div>
									<div class="layui-form-item">
										<label class="layui-form-label">个人照片：</label>
										<input type="hidden" name="info[headimg]" id="headimg" lay-verType="tips" class="layui-input" value="{$info.headimg}">
										<button style="float:left;" type="button" class="layui-btn layui-btn-primary"  onclick="uploader(this)" upload-input="headimg" upload-preview="headimgPreview">上传图片</button>
										<div class="layui-form-mid layui-word-aux" style="margin-left:10px;">建议尺寸：600×600像素</div>
										<div id="headimgPreview" style="float:left;padding-top:10px;padding-left:110px;clear: both;">
											<div class="layui-imgbox" style="width:100px;;height:71px"><div class="layui-imgbox-img"><img src="{$info.headimg}"/></div></div>
										</div>
									</div>
									<div class="layui-form-item">
										<label class="layui-form-label">姓名：</label>
										<div class="layui-input-inline">
											<input type="text" name="info[realname]" lay-verify="required" lay-verType="tips" class="layui-input" value="{$info.realname}">
										</div>
									</div>
									<div class="layui-form-item">
										<label class="layui-form-label">头衔：</label>
										<div class="layui-input-inline">
											<input type="text" name="info[touxian1]" lay-verify="required" lay-verType="tips" class="layui-input" value="{$info.touxian1}">
										</div>
										<div class="layui-input-inline">
											<input type="text" name="info[touxian2]" lay-verType="tips" class="layui-input" value="{$info.touxian2}">
										</div>
										<div class="layui-input-inline">
											<input type="text" name="info[touxian3]" lay-verType="tips" class="layui-input" value="{$info.touxian3}">
										</div>
									</div>
									{foreach $field_list as $field=>$fv}
									{if $fv['isshow'] == 1}
									<div class="layui-form-item">
										<label class="layui-form-label">{$fv.name}：</label>
										<div class="layui-input-inline">
											<input type="text" name="info[{$field}]" class="layui-input" value="{$info[$field]}">
										</div>
									</div>
									{if $field == 'address'}
									<div class="layui-form-item">
										<label class="layui-form-label">经纬度：</label>
										<div class="layui-input-inline" style="width:150px">
											<input type="text" name="info[longitude]" value="{$info['longitude']}" class="layui-input">
										</div>
										<div class="layui-form-mid">-</div>
										<div class="layui-input-inline" style="width:150px">
											<input type="text" name="info[latitude]" value="{$info['latitude']}" class="layui-input">
										</div>
										<button class="layui-btn layui-btn-primary" onclick="choosezuobiao()" style="float:left">选择坐标</button>
									</div>
									{/if}
									{/if}
									{/foreach}
									<div class="layui-form-item">
										<div class="layui-input-block">
											<button class="layui-btn layui-btn-normal" onclick="gonext(2)">下一步:编辑个人简介</button>
											<button class="layui-btn layui-btn-danger" lay-submit lay-filter="formsubmit">提 交</button>
										</div>
									</div>
								</div>
								<div class="layui-tab-item">
									<!-- 详情编辑器 -->
									<?php 
									$pagetitle='文章详情';
									$pagedata= $info['detail'] && json_decode($info['detail']) ? $info['detail'] : '[{"id":"M0000000000000","temp":"richtext","params":{bgcolor:"#FFFFFF",margin_x:"0",margin_y:"5",padding_x:"10",padding_y:"10","quanxian":{"all":true},"platform":{"all":true}},"data":"","other":"","content":""}]';
									?>
									{include file="designer_page/designer_editor" /}

									<div class="layui-form-item">
										<div class="layui-input-block">
											<button class="layui-btn layui-btn-normal" onclick="gonext(1)">上一步:编辑基本信息</button>
											<button class="layui-btn layui-btn-danger" lay-submit lay-filter="formsubmit">提 交</button>
										</div>
									</div>
								</div>
							</div>
						</div>

						
					</div>
					
				</div>
			</div>
    </div>
  </div>
	<script>
	function gonext(layid){
		$(window).scrollTop(0);
		layui.element.tabChange('mytab', layid);
	}
	
	function choosezuobiao(){
		var address = $("input[name='info[address]']").val();
		var longitude = $("input[name='info[longitude]']").val();
		var latitude = $("input[name='info[latitude]']").val();
		var choosezblayer = layer.open({type:2,shadeClose: true,area: ['800px', '560px'],'title': '选择坐标',content: "{:url('DesignerPage/choosezuobiao')}&address="+(address?address:"")+"&jd="+(longitude?longitude:"")+"&wd="+(latitude?latitude:""),btn:['确定','取消'],yes:function(index, layero){
			var longitude = layero.find('iframe').contents().find('#mapjd').val();
			var latitude = layero.find('iframe').contents().find('#mapwd').val();
			$("input[name='info[longitude]']").val(longitude);
			$("input[name='info[latitude]']").val(latitude);
			layer.close(choosezblayer);
		}});
	}
	layui.form.on('submit(formsubmit)', function(obj){
		var field = obj.field
		//field['info[content]'] = ueditor.getContent();
		field['info[detail]'] = geteditordata();
		//console.log(field);return;
		var index = layer.load();
		$.post("{:url('save')}",field,function(data){
			layer.close(index);
			dialog(data.msg,data.status);
			if(data.status == 1){
				setTimeout(function(){
					parent.layer.close(parent.layer.getFrameIndex(window.name));
					parent.tableIns.reload()
				},1000)
			}
		})
	})
  </script>
	{include file="public/copyright"/}
</body>
</html>